package com.qiang.demo04;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Test01 {
    public static void main(String[] args) {
        HashMap<String, Integer> sts = new HashMap<>();
        sts.put("刘备", 23);
        sts.put("关羽", 34);
        sts.put("张飞", 32);
        sts.put("马超", 24);
        sts.put("赵云", 21);
        sts.put("黄忠", 45);
       // System.out.println(sts);

        Integer i = sts.remove("刘备");
        System.out.println(i);


        System.out.println("=======");

        //第一种遍历方法
        Set<String> keyset = sts.keySet();
        for (String key : keyset) {
            Integer integer = sts.get(key);
            System.out.println(key + "//" + integer);
        }

        System.out.println("=======");

        //第二种遍历
        Set<Map.Entry<String, Integer>> entries = sts.entrySet();
        for (Map.Entry<String, Integer> entry : entries) {
            String key = entry.getKey();
            Integer value = entry.getValue();
            System.out.println(key + "//" + value);
        }

        System.out.println("=======");
        //第三种遍历
        sts.forEach((String key,Integer value) -> {
            System.out.println(key+"//"+value);
        });
    }
}
